package com.hpq.user.service.adapter;

import com.hpq.chat.domain.dto.ChatMessageMarkDTO;
import com.hpq.chat.domain.vo.response.msg.ChatMessageResp;
import com.hpq.user.domain.vo.response.websocket.WSFriendApply;
import com.hpq.websocket.domain.enums.WSReqTypeEnum;
import com.hpq.websocket.domain.enums.WSRespTypeEnum;
import com.hpq.websocket.domain.vo.response.WSBaseResp;
import com.hpq.websocket.domain.vo.response.WSMsgMark;
import org.springframework.beans.BeanUtils;

import java.util.Collections;

public class WSAdapter {
    public static WSBaseResp<WSFriendApply> buildApplySend(WSFriendApply wsFriendApply) {
        WSBaseResp<WSFriendApply> wsBaseResp = new WSBaseResp<>();
        wsBaseResp.setType(WSReqTypeEnum.APPLY.getType());
        wsBaseResp.setData(wsFriendApply);
        return wsBaseResp;

    }
    public static WSBaseResp<ChatMessageResp> buildMsgSend(ChatMessageResp msgResp) {
        WSBaseResp<ChatMessageResp> wsBaseResp = new WSBaseResp<>();
        wsBaseResp.setType(WSRespTypeEnum.MESSAGE.getType());
        wsBaseResp.setData(msgResp);
        return wsBaseResp;
    }
    public static WSBaseResp<WSMsgMark> buildMsgMarkSend(ChatMessageMarkDTO dto, Integer markCount) {
        WSMsgMark.WSMsgMarkItem item = new WSMsgMark.WSMsgMarkItem();
        BeanUtils.copyProperties(dto, item);
        item.setMarkCount(markCount);
        WSBaseResp<WSMsgMark> wsBaseResp = new WSBaseResp<>();
        wsBaseResp.setType(WSRespTypeEnum.MARK.getType());
        WSMsgMark mark = new WSMsgMark();
        mark.setMarkList(Collections.singletonList(item));
        wsBaseResp.setData(mark);
        return wsBaseResp;
    }

}
